<template>
  <div>
    <table border="1" width='500'>
      <tr>
        <td>序号</td>
        <td>姓名</td>
        <td>年龄</td>
        <td>性别</td>
        <td>出生年月</td>
      </tr>
      <tr v-for="(item, index) in data" :key="index">
        <td>{{ index }}</td>
        <td>{{ item.name }}</td>
        <td>{{ item.age }}</td>
        <td>{{ item.sex }}</td>
        <td>{{ item.time | FormData }}</td>
      </tr>
    </table>
    <div class="popup">
      <div class="header">
        <span class="close">&times;</span>
        <h3>标题</h3>
      </div>
      <form>
        <div class="form-group">
          <label>姓名：</label>
          <input type="text" placeholder="请输入姓名">
        </div>
        <div class="form-group gender-select">
          <label>性别：</label>
          <input type="radio" name="gender" id="male" value="male">
          <label for="male">男</label>
          <input type="radio" name="gender" id="female" value="female">
          <label for="female">女</label>
        </div>
        <div class="form-group">
          <label>年龄：</label>
          <input type="number" placeholder="请输入年龄"> <!-- 修正原界面的提示文字错误 -->
        </div>
        <div class="form-group">
          <label class="birthday">出生年月：</label>
          <input type="date" placeholder="年/月/日">
        </div>
        <div class="btn-group">
          <button class="btn btn-save">保存</button>
          <button class="btn btn-cancel">取消</button>
        </div>
      </form>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      data: [{
        name: '孙悟空',
        age: 500,
        sex: "男",
        time: 12345568902
      }, {
        name: '猪八戒',
        age: 500,
        sex: "男",
        time: 12345568902
      }, {
        name: '沙悟净',
        age: 500,
        sex: "男",
        time: 12345568902
      },]
    }
  },
  methods: {

  },
  filters: {
    FormData(value) {
      let data = new Date(value)
      // 年
      let yy = data.getFullYear()
      // 月
      let mm = data.getMonth() + 1
      // 日
      let dd = data.getDay() + 1
      // 时
      let hh = data.getHours()
      // 分
      let min = data.getMinutes()
      // 秒
      let ss = data.getSeconds()

      return `${yy}-${mm}-${dd} ${hh}:${min}:${ss}`
    }
  }

}
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.popup {
  width: 400px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
  padding: 25px;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -3%);
}

.header {
  text-align: center;
  margin-bottom: 20px;
  position: relative;
}

.close {
  position: absolute;
  top: 0;
  right: 0;
  font-size: 24px;
  cursor: pointer;
  color: #333;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  margin-bottom: 6px;
  font-size: 14px;
  color: #333;
}

.form-group input {
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  font-size: 14px;
}

.gender-select {
  display: flex;
  align-items: center;
  gap: 15px;
  padding-left: 53px;
}

.gender-select input {
  width: auto;
  margin-right: 5px;
}

.btn-group {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: #fff;
}

.btn-save {
  background: #42b983;
}

.btn-cancel {
  background: #ff4d4f;
}
</style>
